/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package facade;

import domain.Usuario;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;




/**
 *
 * @author Neto
 */
@Stateless
public class LoginFacade implements LoginFacadeLocal {

    @PersistenceContext(unitName = "WEB3-ejbPU")
    private EntityManager entityManager;

    @Override
    public boolean verificarUsuario(Usuario usuario) {
        boolean retorno = false;
        long cont = 0;
        Query query = entityManager.createQuery("select count(0) from Usuario o"
                + " where o.login = '" + usuario.getLogin() + "' and o.senha ='"
                + usuario.getSenha() + "'");
        Object result = (Object) query.getSingleResult();
        cont = (Long) result;
        if(cont ==1){
            retorno = true;          
        }
        
        return retorno;
    }

    
}
